package com.shen.server.controller;


import com.shen.server.pojo.Department;
import com.shen.server.pojo.RespBean;
import com.shen.server.service.IDepartmentService;
import io.swagger.annotations.ApiModelProperty;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author HMF
 * @since 2022-04-10
 */
@RestController
@RequestMapping("/system/basic/department")
public class DepartmentController {

    @Autowired
    private IDepartmentService departmentService;

    /**
     * 获取所有部门
    * @date: 2022/4/19
    * @return
    */

    @ApiOperation(value = "获取所有部门")
    @GetMapping("/")
    public List<Department> getAlldepts(){
        return departmentService.getAlldepts();
    }

    /**
     * 添加一个部门
    * @date: 2022/4/19
    * @param: department
    * @return
    */

    @ApiOperation(value = "添加一个部门")
    @PostMapping("/")
    public RespBean addDept(@RequestBody Department department){
        return departmentService.addDept(department);
    }

    /**
     * 删除一个部门
    * @date: 2022/4/19
    * @return
    */
    @ApiOperation(value = "删除一个部门")
    @DeleteMapping("/{id}")
    public RespBean deleteDept(@PathVariable Integer id){
        return departmentService.deleteDept(id);
    }


}
